/**
 *
 */
package lpny.btview.server.resource;

import java.util.HashMap;
import java.util.Map;

import org.restlet.Context;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.ResourceException;
import org.restlet.resource.Variant;

import any.restlet.gsp.TemplateRepresentation;

/**
 * @author keke
 * @version $Revision: 95 $
 */
public class GwtHomeResource extends Resource {
	private String	gwtBootPath;

	@Override
	public void init(final Context context, final Request request,
	        final Response response) {
		super.init(context, request, response);
		getVariants().add(new Variant(MediaType.TEXT_HTML));
	}

	@Override
	public Representation represent(final Variant variant)
	        throws ResourceException {
		final Map<String, Object> binding = new HashMap<String, Object>();
		binding.put("title", "BtView");
		binding.put("csses", null);
		binding.put("gwtBootPath", gwtBootPath);
		binding.put("main", "main");
		return new TemplateRepresentation(Thread.currentThread()
		        .getContextClassLoader().getResourceAsStream(
		                "static/gsp/gwt_home.gt"), binding, variant
		        .getMediaType());
	}

	public void setGwtBootPath(final String gwtModule) {
		gwtBootPath = gwtModule;
	}
}
